using System;

namespace npomodoro.Core
{
    public abstract class TimedActivityBase
    {
        private DateTime m_StartTime;
        private DateTime m_EndTime;
        protected double m_RunTimeInSeconds;

        protected TimedActivityBase(double runTimeInSeconds)
        {
            m_RunTimeInSeconds = runTimeInSeconds;
        }

        public TimeSpan CurrentRunTime
        {
            get { return DateTime.Now - m_StartTime; }
        }

        public TimeSpan TotalRunTime
        {
            get { return m_EndTime - m_StartTime; }
        }

        public TimeSpan RemainingTime
        {
            get { return m_EndTime - DateTime.Now; }
        }

        public abstract string Name { get; }

        public void Start()
        {
            m_StartTime = DateTime.Now;
            m_EndTime = m_StartTime.AddSeconds(m_RunTimeInSeconds);
        }

        public bool IsFinished()
        {
            return DateTime.Now >= m_EndTime;
        }
    }
}